/*
 * (C) Copyright 2009
 * Sean Chiang, <n2i911@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <ucos_ii.h>

#if OS_DEBUG_EN > 0
void OSDebugInit(void)
{
	return;
}
#endif

void OSInitHookBegin (void)
{
	return;
}

void OSInitHookEnd (void)
{
	return;
}

void OSTaskCreateHook(OS_TCB *ptcb)
{
	return;
}

void OSTaskDelHook(OS_TCB *ptcb)
{
	return;
}

void OSTaskIdleHook(void)
{
	return;
}

void OSTaskStatHook(void)
{
	return;
}

OS_STK *OSTaskStkInit(void(*task)(void *p_arg),
                      void *p_arg,
                      OS_STK *ptos,
                      INT16U opt)
{
	/* This function is called by OSTaskCreate() or OSTaskCreateExt() */

	OS_STK *stk = (OS_STK *) ptos;

	/*
	 * r13, SP
	 * r15, PC
	 */
	*stk-- = (OS_STK) task;		//r15, PC, program counter
	*stk-- = (OS_STK) 0x14141414;	//r14, LR, return address
	*stk-- = (OS_STK) 0x12121212;	//r12
	*stk-- = (OS_STK) 0x11111111;	//r11
	*stk-- = (OS_STK) 0x10101010;	//r10
	*stk-- = (OS_STK) 0x09090909;	//r9
	*stk-- = (OS_STK) 0x08080808;	//r8
	*stk-- = (OS_STK) 0x07070707;	//r7
	*stk-- = (OS_STK) 0x06060606;	//r6
	*stk-- = (OS_STK) 0x05050505;	//r5
	*stk-- = (OS_STK) 0x04040404;	//r4
	*stk-- = (OS_STK) 0x03030303;	//r3
	*stk-- = (OS_STK) 0x02020202;	//r2
	*stk-- = (OS_STK) 0x01010101;	//r1
	*stk-- = (OS_STK) p_arg;	//r0

	*stk = (OS_STK) 0x13;		//spsr, SVC mode in default

	return stk;			// stack of pointer
}

#if OS_TASK_SW_HOOK_EN > 0
void OSTaskSwHook(void)
{
	return;
}
#endif

void OSTCBInitHook(OS_TCB *ptcb)
{
	return;
}

#if OS_TIME_TICK_HOOK_EN > 0
void OSTimeTickHook(void)
{
	return;
}
#endif
